{extend name="common:base" /}

{block name="title"}我的二手 - 天佑二手货{/block}
{block name="page"}goods{/block}

{block name="main"}
<div class="am-g am-g-fixed">
    <div class="am-u-sm-12">
        <h1 class="am-margin-top">我的二手货</h1>
        <ul class="sort am-cf">
            <li>排序规则:</li>
            <li><a id="sort-deadline" href="{:url('goods/goodsList', ['sort'=>'deadline'])}">剩余时间</a></li>
            <li><a id="sort-hits" href="{:url('goods/goodsList', ['sort'=>'hits'])}">点击量</a></li>
            <li><a id="sort-time" href="{:url('goods/goodsList', ['sort'=>'time'])}">创建时间</a></li>
            <script type="text/javascript">$('#sort-{$sort}').addClass('current');</script>
        </ul>
    </div>
    <ul class="am-avg-sm-4 goods-list">
    {volist name="data" id="vo"}
        <li class="good">
            <div class="good-box">
                <a href="{:url('goods/detail',['good_id' => $vo['good_id']])}">
                    <h4 class="am-text-truncate am-margin-bottom-0 am-padding-bottom" title="{$vo.title}">{$vo.title}</h4>
                    <div class="thumb" style="background-image: url(__ROOT__{$vo.thumb|default='/static/images/no-thumb.png'})">
                        {if condition="$vo.expand.photos_count gt 1"}
                        <span class="am-badge am-badge-success badge">{$vo.expand.photos_count}</span>
                        {/if}
                    </div>
                </a>
                <p class="deadline">剩余时间: {$vo.deadline|get_time_diff} <a class="operate" href="#">续期</a></p>
                <p class="other">
                    <span class="am-margin-right price" title="{$vo.price} 元">
                        <i class="am-icon am-icon-cny"></i> {$vo.price}
                    </span>
                    <span class="am-margin-right hits" title="{$vo.hits} 人看过">
                        <i class="am-icon am-icon-eye"></i> {$vo.hits}
                    </span>
                    <span class="operate am-fr">
                        <a href="javascript:;" onclick="ajax_recycle({$vo.good_id})" title="删除该二手货">
                            <i class="am-icon am-text-danger am-icon-remove"></i>
                        </a>
                        <a href="#" title="修改信息"><i class="am-icon am-icon-gear"></i></a>
                    </span>
                </p>
            </div>
        </li>
    {/volist}
    </ul>
    {$data->render()}
</div>
{/block}

{block name="js"}
<script type="text/javascript">
function ajax_recycle(good_id) {
    $.get("{:url('goods/recycle')}?good_id=" + good_id, function(data) {
        $alert = $('#am-alert');
        $alert.find('.content').text(data.msg);
        $alert.modal('open');
        if (data.code) {
            setTimeout(function() {
                location.reload();
            }, '800')
        }
    });
}
</script>
{/block}